package com.jic.market.converter;

import com.jic.market.entity.PromotionEntity;
import com.jic.market.response.PromotionResponse;

import java.util.List;
import java.util.stream.Collectors;

/**
 * description: PromotionConverter
 * date: 2020/1/10 15:51
 * author: wangys
 * version: 1.0
 */
public class PromotionConverter {
    public static PromotionResponse toRes(PromotionEntity entity) {
        PromotionResponse response = new PromotionResponse();
        if (entity != null) {
            response.setCreatorName(entity.getCreatorName());
            response.setPromType(entity.getPromType());
            response.setCreateTime(entity.getCreateTime());
            response.setCreateMerchantName(entity.getCreateMerchantName());
            response.setCreatorName(entity.getCreatorName());
            response.setFrontPromType(entity.getFrontPromType());
            response.setId(entity.getId());
            response.setRemark(entity.getRemark());
            response.setEndTime(entity.getEndTime());
            response.setStartTime(entity.getStartTime());
            response.setStatus(entity.getStatus());
            response.setContentType(entity.getContentType());
            response.setCreateMerchantId(entity.getCreateMerchantId());
            response.setCreateTime(entity.getCreateTime());
            response.setGiftType(entity.getGiftType());
            response.setRuleInfo(entity.getRuleInfo());
            response.setSeckillFlag(entity.getSeckillFlag());
            response.setOverlayAppNum(entity.getOverlayAppNum());
        }
        return response;
    }

    public List<PromotionResponse> toRes(List<PromotionEntity> entities) {
        if (entities == null) {
            return null;
        }
        return entities.stream().map(x -> {
            return toRes(x);
        }).collect(Collectors.toList());
    }
}
